home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20041116-20060924 / 000313_rock_spambust_violin@yahoo.com_Tue Apr 25 12:16:12 2006.msg < prev    next >
Internet Message Format  |  2020-01-01  |  5KB

  1. Path: newsmaster.cc.columbia.edu!newsfeed.nyu.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!oleane.net!oleane!news.in2p3.fr!in2p3.fr!proxad.net!216.239.36.134.MISMATCH!postnews.google.com!z34g2000cwc.googlegroups.com!not-for-mail
  2. From: "tomviolin" <rock_spambust_violin@yahoo.com>
  3. Newsgroups: comp.protocols.kermit.misc
  4. Subject: Re: speed of script execution
  5. Date: 21 Apr 2006 16:22:35 -0700
  6. Organization: http://groups.google.com
  7. Lines: 120
  8. Message-ID: <1145661755.906411.37550@z34g2000cwc.googlegroups.com>
  9. References: <1145524573.729587.320320@z34g2000cwc.googlegroups.com>
  10.    <slrne4f65k.djh.fdc@sesame.cc.columbia.edu>
  11. NNTP-Posting-Host: 129.89.149.237
  12. Mime-Version: 1.0
  13. Content-Type: text/plain; charset="iso-8859-1"
  14. X-Trace: posting.google.com 1145661762 19541 127.0.0.1 (21 Apr 2006 23:22:42 GMT)
  15. X-Complaints-To: groups-abuse@google.com
  16. NNTP-Posting-Date: Fri, 21 Apr 2006 23:22:42 +0000 (UTC)
  17. User-Agent: G2/0.2
  18. X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.2) Gecko/20060308 Firefox/1.5.0.2,gzip(gfe),gzip(gfe)
  19. Complaints-To: groups-abuse@google.com
  20. Injection-Info: z34g2000cwc.googlegroups.com; posting-host=129.89.149.237;
  21.    posting-account=ornCOQwAAAAyCG4a7NOAj_SMr54FiqNu
  22. Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:15572
  23.  
  24. Frank da Cruz wrote:
  25. > On 2006-04-20, tomviolin <rock_spambust_violin@yahoo.com> wrote:
  26. > : Can anyone tell me why there is such a huge time discrepency between
  27. > : the execution of the following scripts.  The only difference is the
  28. > : curly braces.  I'm running on an ARM SBC from a flash drive, if that
  29. > : makes any difference.
  30. > :
  31. > : ---- testx.ksc ----
  32. > : #!/usr/bin/kermit +
  33. > : {  assign \%p 1, set line  /dev/ttyAM\%p }
  34. > : { close }
  35. > : exit
  36. > :
  37. > : ---- testy.ksc ----
  38. > : #!/usr/bin/kermit +
  39. > : assign \%p 1, set line  /dev/ttyAM\%p
  40. > : close
  41. > : exit
  42. > :
  43. > : -- test results --
  44. > : $ time ./testx.ksc
  45. > : real    0m 0.60s
  46. > : user    0m 0.04s
  47. > : sys     0m 0.06s
  48. > :
  49. > : $ time ./testy.ksc
  50. > : real    0m 0.09s
  51. > : user    0m 0.05s
  52. > : sys     0m 0.04s
  53. > :
  54. > :
  55. > As in C, the braces mark a block, entry to and exit from which carries some
  56. > setup and takedown cost.  When you have only one or two statements in the
  57. > block, that cost is a lot higher, proportionally, than if you have a lot of
  58. > statements in it.
  59. >
  60. [ stuff skipped ]
  61. >
  62. > If you have encountered a serious bottleneck in a real application, let me
  63. > know, maybe something can be done about it.
  64. >
  65. > - Frank
  66.  
  67. I have played a bit with my examples as well as my larger system, and
  68. have generated the following two examples, changed only with addition
  69. of a couple of echo statements:
  70.  
  71. -- testx.ksc --
  72. #!/usr/bin/kermit +
  73. {  assign \%p 1, set line  /dev/ttyAM\%p }
  74. echo test 1
  75. { close }
  76. echo test 2
  77. exit
  78.  
  79. -- testy.ksc --
  80. #!/usr/bin/kermit +
  81. assign \%p 1, set line  /dev/ttyAM\%p
  82. echo test 1
  83. close
  84. echo test 2
  85. exit
  86.  
  87. Again, testy.ksc runs much faster.  However, I am observing that, with
  88. the slower testx.ksc script, that "test 1" appears almost instantly,
  89. and that the vast majority of the 0.6 seconds is spent between "test 1"
  90. and "test 2" appearing, with "test 2" appearing right before the
  91. program ends.
  92.  
  93. Then, I further modified testx.ksc as follows:
  94.  
  95. --- testx1.ksc ---
  96. #!/usr/bin/kermit +
  97. {  assign \%p 1, set line  /dev/ttyAM\%p }
  98. echo test 1
  99. { echo test 1a, close, echo test 1b  }
  100. echo test 2
  101. exit
  102.  
  103. Now of course the output is:
  104.  
  105. $ ./testx1.ksc
  106. test 1
  107. test 1a
  108. test 1b
  109. test 2
  110.  
  111. and the vast majority of the pause is between the appearance of "test
  112. 1a" and "test 1b", thus demonstrating that the "close" statement is the
  113. cause of the problem.
  114.  
  115. PLUS, look at the "time" output again (results very similar to the
  116. prior examples):
  117.  
  118. $ time ./testx.ksc
  119. test 1
  120. test 2
  121. real    0m 0.63s
  122. user    0m 0.05s
  123. sys     0m 0.07s
  124.  
  125. $ time ./testy.ksc
  126. test 1
  127. test 2
  128. real    0m 0.09s
  129. user    0m 0.04s
  130. sys     0m 0.05s
  131.  
  132. Notice that the "user" and "sys" times for testx.ksc and testy.ksc are
  133. comparable and that for testy.ksc, the sum of "user" and "sys" are
  134. close to (or apparently exactly) the value for "real".  However, the
  135. "real" time for testx.ksc is way off the chart compared to the sum of
  136. "user" and "sys" thus seeming to indicate that kermit is sleeping,
  137. waiting for I/O, or otherwise in some sort of suspended state for about
  138. 0.51s.  Doesn't seem like time spent in setup or takedown of data
  139. structures to me.
  140.  
  141. It would appear that the "close" statement is the culprit.  Why?  And
  142. why does it delay only for testx.ksc and not testy.ksc?
  143.